package com.yuju.group.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yuju.common.core.dao.IBaseDao;
import com.yuju.common.core.service.AbstractBaseService;
import com.yuju.group.dao.ISeqCodeDao;
import com.yuju.group.dao.entity.SeqCode;
import com.yuju.group.model.SeqCodeModel;
import com.yuju.group.service.ISeqCodeService;
import com.yuju.util.Utils;

/**
 * 
 * 类名：SeqCodeServiceImpl  <br />
 *
 * 功能：序列号Service实现
 *
 * @author : xuehj <br />
 * @Date : 2017年12月2日 上午8:59:28  <br />
 * @version : 1.1 <br />
 */
@Service
public class SeqCodeServiceImpl extends AbstractBaseService<SeqCodeModel, SeqCode, String> implements ISeqCodeService {
	@Autowired
	private ISeqCodeDao seqCodeDao;

	@Override
	public IBaseDao<SeqCodeModel, SeqCode, String> getDao() {
		// TODO Auto-generated method stub
		return seqCodeDao;
	}
	
	@Override
	public int save(SeqCodeModel model) {
		Date date = new Date();
		model.setId(Utils.getUUID());
		model.setGmtCreate(date);
		model.setGmtModified(date);
		return super.save(model);
	}

	@Override
	public int update(SeqCodeModel model) {
		Date date = new Date();
		model.setGmtModified(date);
		return super.updateSelective(model);
	}

	@Override
	public boolean initGroupSeqCode(String groupId) {
		int rows = seqCodeDao.initGroupSeqCode(groupId);
		return rows > 0 ? true : false;
	}

	@Override
	public boolean initHotelSeqCode(String groupId, String hotelId) {
		int rows = seqCodeDao.initHotelSeqCode(groupId, hotelId);
		return rows > 0 ? true : false;
	}
}
